define(['egis'], function (egis) {
    Window.deserializer = Window.deserializer || new egis.core.Deserializer();
    Window.container = Window.container || {};
    dsBridge.register('create_TokenManager', function (sourceId, url, clientId, clientSecret) {
        var restHttp = new egis.core.RestHttp({
            token: undefined
        });
        var tokenService = new egis.ews.TokenService({
            url: url,
            http: restHttp
        });

        var tokenManager = new egis.ews.TokenManager({
            tokenService: tokenService,
            clientId: clientId,
            clientSecret: clientSecret
        });
        Window.container[sourceId] = tokenManager;
    })

    dsBridge.registerAsyn('TokenManager_start', function (sourceId) {
        var tokenManager = Window.container[sourceId];
        tokenManager.start();
    })

    dsBridge.registerAsyn('TokenManager_stop', function (sourceId, responseCallback) {
        var tokenManager = Window.container[sourceId];
        tokenManager.stop();
    })
})